package com.example.myapplication_2.mapper;


import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class SymptomMapper {
    private List<String> symptomList; //所有症状集合
    public SymptomMapper(){
        symptomList = new ArrayList<>();
        symptomList.add("皮肤干燥");
        symptomList.add("皮肤色暗");
        symptomList.add("眼睛有血丝");
        symptomList.add("痤疮");
        symptomList.add("脱发");
        symptomList.add("月经不调");
        symptomList.add("头痛");
        symptomList.add("痛经");
        symptomList.add("乳房胀痛");
        symptomList.add("减肥");
        symptomList.add("口黏腻");
        symptomList.add("咳嗽");
        symptomList.add("痰多");
        symptomList.add("便秘");
        symptomList.add("眼干");
        symptomList.add("口干");
        symptomList.add("失眠多梦");
        symptomList.add("食欲减退");
        symptomList.add("鼻腔干燥");
        symptomList.add("皮肤细纹");
        symptomList.add("头晕");
        symptomList.add("腰痛");
        symptomList.add("皮肤过敏");
        symptomList.add("鼻腔过敏");
        symptomList.add("哮喘");
        symptomList.add("出虚汗");
        symptomList.add("乏力");
        symptomList.add("精神抑郁");
        symptomList.add("易感冒");
        symptomList.add("手脚凉");
        symptomList.add("口臭");
        symptomList.add("大便稀");
        symptomList.add("白带多");
    }

    /**
     * 查找除usedSymptom以外的任意八个症状字符串
     * @param usedSymptom 标签内已有的症状信息集合
     */
    public List<String> selectSymptom(List<String> usedSymptom){
        int i,j;
        boolean isExit = false;
        List<String> result = new ArrayList<>();
        Random rand = new Random();
        while(result.size()<8){
            isExit = false;
            int num = rand.nextInt((symptomList.size()));//产生0-symptomList.size()-1之间的随机数
            for(i=0;i<result.size();i++){
                if(symptomList.get(num).equals(result.get(i))){
                    isExit = true;
                    break;
                }
            }
            if(isExit){
                continue;
            }
            for(j=0;j<usedSymptom.size();j++){
                if(symptomList.get(num).equals(usedSymptom.get(j))){
                    isExit = true;
                    break;
                }
            }
            if(!isExit){
                result.add(symptomList.get(num));
            }
        }
        return result;
    }

    /**
     * 获取所有症状
     * @return 所有症状集合
     */
    public List<String> selectAllSymptom(){

        return symptomList;
    }

    /**
     * 按关键字搜索症状
     * @param word 关键字
     * @return 包含关键字的症状集合
     */
    public List<String> selectSymptomByWord(String word){
        List<String> result = new ArrayList<>();
        for(int i=0;i<symptomList.size();i++){
            if(symptomList.get(i).contains(word)){
                result.add(symptomList.get(i));
            }
        }
        return result;
    }


    /**
     * 获得用户选中的症状信息
     * @param confirmSymptom 点击确认按钮后获得的症状信息
     */
    public void confirmSymptom(List<String> confirmSymptom){

    }

}

